package ro.cityprojects.adminloc.entities;

import javax.persistence.*;
import java.io.Serializable;

/**
 * ConsumptionReportPK class
 *
 * @author bogdan.solga
 * 
 * Date: 13.06.2013, time: 17:47
 */
public class ConsumptionReportPK implements Serializable {

    @Id
    @JoinColumn(name = "REPORT_ID", nullable = false, insertable = true, updatable = true)
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Report report;

    @Id
    @JoinColumn(name = "CONSUMPTION_ID", nullable = false, insertable = true, updatable = true)
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Consumption consumption;

    public Report getReport() {
        return report;
    }

    public void setReport(Report report) {
        this.report = report;
    }

    public Consumption getConsumption() {
        return consumption;
    }

    public void setConsumption(Consumption consumption) {
        this.consumption = consumption;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ConsumptionReportPK that = (ConsumptionReportPK) o;

        if (consumption != null ? !consumption.equals(that.consumption) : that.consumption != null) return false;
        if (report != null ? !report.equals(that.report) : that.report != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = report != null ? report.hashCode() : 0;
        result = 31 * result + (consumption != null ? consumption.hashCode() : 0);
        return result;
    }
}
